package uo.ri.bussiness.impl.admin;

import java.sql.SQLException;

import uo.ri.common.BusinessException;
import alb.util.jdbc.Jdbc;

public class AddMechanic extends MechanicBase{
	
	
	private String nombre;
	private String apellidos;
	
	public AddMechanic(String nombre, String apellidos){
		this.nombre = nombre;
		this.apellidos = apellidos;
	}
	
	public void execute() throws BusinessException {
		
		try {
			prepareDB();
			mecanicosGateway.save(nombre, apellidos);
			connection.commit();
			
		} catch (SQLException e) {
			try {
				connection.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			throw new RuntimeException(e);
		}
		finally {
			Jdbc.close(connection);
		}
	}

}
